package com.fanrui.code.util.core;

/**
 * 版本检测
 * @author Administrator
 *
 */
public class VersionUtil {

	private VersionUtil() {}
	
	private static class VersionUtilSingleton {
		private static VersionUtil instance = new VersionUtil();
	}
	
	public static VersionUtil getInstance() {
		return VersionUtilSingleton.instance;
	}
	
	/**
	 * 最低可支持版本（低于此版本将强制更新）
	 */
	private int[] appVersionMin;

	/**
	 * 当前最高版本（低于此版本将提示更新）
	 */
	private int[] appVersionMax;
	
	public void init(String minVersion, String maxVersion ){
		if(appVersionMin != null && appVersionMax != null){
			throw new IllegalStateException("VersionUtil已经初始化过了，不能重复初始化！");
		}
		String[] versionMin = minVersion.split("\\.");
		String[] versionMax = maxVersion.split("\\.");

		appVersionMin = new int[versionMin.length];
		appVersionMax = new int[versionMin.length];

		for (int i = 0; i < versionMin.length; i++) {
			appVersionMin[i] = Integer.parseInt(versionMin[i]);
			appVersionMax[i] = Integer.parseInt(versionMax[i]);
		}
	}

	public boolean mustBeUpdate(String appVersion) {
		return false;
	}
	
}
